import {
  NConfigProvider,
  NLoadingBarProvider,
  NMessageProvider,
  NNotificationProvider,
  darkTheme,
  zhCN,
  dateZhCN,
  NDialogProvider
} from 'naive-ui'
import GlobalInject from "./GlobalInject";
import {Component, ComponentProps, VueComponent} from "vue3-oop";
import AppService from "@/service/AppService";
import SettingSercice from "@/service/SettingService";
import {SkipSelf} from "injection-js";

interface IProps {}
@Component()
export default class GlobalProvider extends VueComponent<IProps> {
  static defaultProps: ComponentProps<IProps> = []

  constructor(
    @SkipSelf() private appService: AppService,
    @SkipSelf() private settingSercice: SettingSercice
  ) {
    super();
  }

  render() {
    const slots = useSlots()
    let { globalTheme } = this.settingSercice.settings
    return (
      <NConfigProvider
        theme={globalTheme === 'darkTheme' ? darkTheme : undefined}
        dateLocale={dateZhCN}
        locale={zhCN}
      >
        <NDialogProvider>
          <NNotificationProvider>
            <NMessageProvider>
              <NLoadingBarProvider>
                <GlobalInject>
                  {slots.default!()}
                </GlobalInject>
              </NLoadingBarProvider>
            </NMessageProvider>
          </NNotificationProvider>
        </NDialogProvider>
      </NConfigProvider>
    )
  }
}
